﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace NPMonitor.Web.UserControls
{
    public partial class TimeChart : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            timeLine.Style.Add("width", "160px;");
            if (Total != 0)
            {
                liBlocked.Style.Add("width", ((Blocked / Total)*100).ToString("N2")+"%");
                liSend.Style.Add("width", ((Send / Total)*100).ToString("N2")+"%");
                liWait.Style.Add("width", ((Wait / Total)*100).ToString("N2")+"%");
                liReceive.Style.Add("width", ((Receive / Total)*100).ToString("N2")+"%");
                liCacheRead.Style.Add("width", ((CacheRead / Total)*100).ToString("N2")+"%");
                liNetwork.Style.Add("width", ((Network / Total)*100).ToString("N2")+"%");
            }
        }

        public decimal Blocked
        {
            get;
            set;
        }
        public decimal Send
        { 
            get; set; 
        }
        public decimal Wait
        {
            get;
            set;
        }
        public decimal Receive
        {
            get;
            set;
        }
        public decimal CacheRead
        {
            get;
            set;
        }
        public decimal Network
        {
            get;
            set;
        }

        private decimal Total
        {
            get
            {
                return Blocked + Send + Wait + Receive + CacheRead + Network;
            }
        }
    }
}